package com.ctv.my.customview.MaiCustomView.CitySelector;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

import com.ctv.my.customview.MaiCustomView.CitySelector.bean.City;
import com.ctv.my.customview.MaiCustomView.CitySelector.view.CitySelectorView;
import com.ctv.my.customview.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ms on 2017/7/11.
 */

public class CitySelectorActivity extends Activity {
    private List<City> hotList = new ArrayList<>();
    private CitySelectorView citySelectorView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_city_selector);
        citySelectorView = (CitySelectorView) findViewById(R.id.cityView);
        for (int i = 0; i < 10; i++) {
            City city = new City();
            city.setName("北京");
            city.setCode("11010" + i);
            hotList.add(city);
        }
        City location = new City();
        location.setName("深圳");
        citySelectorView.setData(location, hotList);
        citySelectorView.setSelectClickCallback(new CitySelectorView.SelectClickCallback() {
            @Override
            public void chooseCity(City city) {
                Toast.makeText(CitySelectorActivity.this, "编码:" + city.getCode() + "--城市:" + city.getName(), Toast.LENGTH_SHORT).show();
            }
        });
    }
}
